//
//  FWComHeaterView.m
//  BirdLoveSheep
//
//  Created by wwj on 16/3/29.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "FWComHeaterView.h"
#import "FWEssenceCell.h"
#import "FWTopicFrameModel.h"
#import "FWTopicModel.h"
@interface FWComHeaterView ()
@property (weak, nonatomic) FWEssenceCell *cell;
@property (strong, nonatomic) NSArray *topCmt;
@property (assign, nonatomic) CGFloat cellHeight;
@end

@implementation FWComHeaterView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

-(void)setModelF:(FWTopicFrameModel *)modelF{
    _modelF = modelF;
    FWEssenceCell *cell = [FWEssenceCell essenceCell];
    self.topCmt = _modelF.topic.top_cmt;
    self.cellHeight = _modelF.cellHeight;
    
    if (_modelF.topic.top_cmt.firstObject) {
        _modelF.topic.top_cmt = nil;
        _modelF.cellHeight = _modelF.cellHeight - _modelF.topCommentH - TOPCOMMH - TBMARGIN;
    }
    
    cell.modelF = _modelF;
    cell.frame = CGRectMake(0, 0, self.width, 0);
    [self addSubview:cell];
    self.cell = cell;
}

- (void)setFrame:(CGRect)frame{
    frame.size = CGSizeMake(kScreenW, self.cell.height);
    [super setFrame: frame];
}

- (void)dealloc{
    _modelF.topic.top_cmt = self.topCmt;
    _modelF.cellHeight = self.cellHeight;
}

@end
